//微信红包
#include <map>
class Gift {
public:
    int getValue(vector<int> gifts, int n) {
        // write code here
        map<int,int> cm;
        for(auto e:gifts)
        {
            cm[e]++;
        }
        auto it=cm.begin();
        while(it!=cm.end())
        {
            if(it->second>=(n/2))
                return it->first;
            else
                ++it;
        }
        return 0;
    }
};


//字符串距离
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int Levenshein(string& str1,string& str2)
{
   if(str1.empty()||str2.empty())
        return max(str1.size(),str2.size());
    
    int len1=str1.size();
    int len2=str2.size();
    vector<vector<int>> MSC(len1+1,vector<int>(len2+1,0));
    for(int i=0;i<=len1;++i)
    {
        MSC[i][0]=i;
    }
    for(int j=0;j<=len2;++j)
    {
        MSC[0][j]=j;
    }
    for(int i=1;i<=len1;++i)
    {
        for(int j=1;j<=len2;++j)
        {
            if(str1[i-1]==str2[j-1])
            {
                MSC[i][j]=min(MSC[i-1][j],MSC[i][j-1])+1;
                MSC[i][j]=min(MSC[i][j],MSC[i-1][j-1]);    
            }
            else
            {
             MSC[i][j]=min(MSC[i-1][j],MSC[i][j-1])+1;
             MSC[i][j]=min(MSC[i][j],1+MSC[i-1][j-1]);    
            }
        }
    }
    return MSC[len1][len2];
}
int main()
{
    string str1,str2;
    while(cin>>str1>>str2)
    cout<<Levenshein(str1,str2)<<endl;
    return 0;
}